"""
f=open("my_diaiy.txt","a",encoding="utf-8")
a=input("输入")
f.write(f"\n{a}")
f.flush()
for line in open("my_diaiy.txt", "r",encoding="utf-8"):
    print(line)
with open("my_diaiy.txt", "r",encoding="utf-8") as f:
    con=f.read()
    s1=con.count("python")
    print(s1)
"""
with open("python.txt","r+",encoding="utf-8") as f,open("python.txt.bak","w",encoding="utf-8") as f2:
    s=f.read()
    f2.write(s)
    s1=""
    for line in s.split("\n"):
        if line.find("测试")==-1:
            s1+=line+"\n"
    f.seek(0)
    f.truncate()
    f.write(s1)




